package com.shiguiwu.springmybatis.designpattern.bridge.pay;

import com.shiguiwu.springmybatis.designpattern.bridge.pay.channel.Pay;
import com.shiguiwu.springmybatis.designpattern.bridge.pay.channel.WxPay;
import com.shiguiwu.springmybatis.designpattern.bridge.pay.mode.PayFaceMode;
import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;

/**
 * @description: 支付服务
 * @author: stone
 * @date: Created by 2021/8/24 12:20
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.designpattern.bridge.pay
 */
@Slf4j
public class PayController {


    /**
     * @param uId         用户id
     * @param tradeId     交易id
     * @param amount      金额
     * @param channelType 支付渠道
     * @param modeType    支付类型
     * @return 失败或者成功
     */
    public boolean doPay(String uId, String tradeId, BigDecimal amount, int channelType, int modeType) {

        //微信支付
        if (1 == channelType) {
            log.info("模拟微信渠道支付划账开始。uId:{},tradeId:{},amount:{}", uId, tradeId, amount);
            if (1 == modeType) {
                log.info("密码支付，风控校验环境安全");

            } else if (2 == modeType) {
                log.info("人脸支付，风控校验脸部识别");

            } else if (3 == modeType) {
                log.info("指纹支付，风控校验指纹识别");
            }
            //支付宝
        } else if (2 == channelType) {
            log.info("模拟支付宝渠道支付划账开始。uId:{},tradeId:{},amount:{}", uId, tradeId, amount);
            if (1 == modeType) {
                log.info("密码支付，风控校验环境安全");

            } else if (2 == modeType) {
                log.info("人脸支付，风控校验脸部识别");

            } else if (3 == modeType) {
                log.info("指纹支付，风控校验指纹识别");
            }
        }

        return false;
    }


    public void doPayPlus(String uId, String tradeId, BigDecimal amount) {
        Pay wxPay = new WxPay(new PayFaceMode());
        wxPay.transfer(uId, tradeId, amount);
    }
}
